
class ImagesPlugin:
	def __init__(self):
		# put all the links this plugins supports here - it will be used to filter supported URLs
		self.supported_sites = ['www.imagebeaver.com', 'imagesocket.com', 'www.shareapic.net']
		self.supported_urls = ['www.imagebeaver.com/view.php', '//imagesocket.com', 'www.shareapic.net/content']
		self.cookies_to_block = []

	def get(self, url):
		"""Get the file from the url"""
		if url.find('www.imagebeaver.com/view.php') != -1:
			filter = 'www1.imagebeaver.com'
		elif url.find('//imagesocket.com') != -1:
			filter = 'content.imagesocket.com/images/'
		elif url.find('www.shareapic.net') != -1:
			filter = 'images.shareapic.net'

		url = get_img_url(url, filter)

		local_file = get_filename_from_url(url)
		download_file_with_retries(local_file, url)
		config.report.report_finish(local_file)

	def url_matches(self, url):
		"""Check whether we support this URL"""
		for l in self.supported_urls:
			if url.find(l) != -1:
				return True
		return False

	def version(self):
		"""Return plugin version - when interface changes, the version changes"""
		return 1

modules = [ImagesPlugin()]
